columnview: Make right-aligned content work
authorMatthias Clasen <mclasen@redhat.com>
Mon, 19 Oct 2020 12:42:33 +0000 (08:42 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 19 Oct 2020 13:39:07 +0000 (09:39 -0400)
Make right-aligned content work in resized columns.
There is currently no way to make a title right-aligned,
but we can still make it work correctly. This is a follow
up to 7eb0ae39c5549bfaa4e.

Fixes: #3276
gtk/gtkcolumnviewcell.c
gtk/gtkcolumnviewtitle.c

index f7db70e04f9de688030a30b086d21fa6ad555e9f..1ada1b4292b614d77347651f11b564553e53e96b 100644 (file)
@@ -124,15 +124,15 @@ gtk_column_view_cell_size_allocate (GtkWidget *widget,
                                     int        height,
                                     int        baseline)
 {
-  GtkColumnViewCell *self = GTK_COLUMN_VIEW_CELL (widget);
   GtkWidget *child = gtk_widget_get_first_child (widget);
 
   if (child)
     {
-      if (gtk_column_view_column_get_fixed_width (self->column) > -1)
-        gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, NULL, &width, NULL, NULL);
+      int min;
+
+      gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
 
-      gtk_widget_allocate (child, width, height, baseline, NULL);
+      gtk_widget_allocate (child, MAX (min, width), height, baseline, NULL);
     }
 }
 
index f2cb4fca835d74aaa569500105f2953ab0aa14b6..c76c8a9a8b391484aca6a611cdd9029ce8c5c284 100644 (file)
@@ -136,10 +136,11 @@ gtk_column_view_title_size_allocate (GtkWidget *widget,
 
   if (child)
     {
-      if (gtk_column_view_column_get_fixed_width (self->column) > -1)
-        gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, NULL, &width, NULL, NULL);
+      int min;
 
-      gtk_widget_allocate (child, width, height, baseline, NULL);
+      gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
+
+      gtk_widget_allocate (child, MAX (min, width), height, baseline, NULL);
     }
 
   if (self->popup_menu)